import pgzrun
pb = True
WIDTH = 195
HEIGHT = 195
white = Actor('white')
black = Actor('black')
board = Actor('board')
black_l = []
white_l = []
board.pos = (97.5,97.5)
rect_size = 195/8
def boolrev():
    global pb
    if pb == False:
        pb = True
    else:
        pb = False

#def legal():           用于判断是否可下
        


def do(pb,rect_pos):
    global black_l,white_l
    if pb == True:
        black_l.append(black)
        black_l[-1].pos = rect_pos
    else:
        white_l.append(white)
        white_l[-1].pos = rect_pos

def on_mouse_down(pos):
    global black_l,white_l,pb
    boolrev()
    print(pb)
    do(pb,rectpos(pos))
    print(pos)
    
def rectpos(pos):
    return(pos[0]//rect_size,pos[1]//rect_size)
    

def draw():
    board.draw()
    for i in white_l:
        i.draw()
    for i in black_l:
        i.draw() 
    
pgzrun.go()